let list = document.querySelector('.list')
let span = document.querySelector('span')
let foot = document.querySelector('.footer')
fetch('http://chst.vip:1234/api/getcoupon')
.then(body=>body.json())
.then(res=>{
    let arr = res.result
    console.log(arr)
    let domStr = ''
    arr.forEach(item=>{
        domStr+=`<div><img src="../images/w.jpg" couponid=${item.couponId}>
        <p>${item.couponTitle}</p>
        </div>`
        list.innerHTML = domStr
    })
})
list.onclick=function(e){
    console.log(e.target)
    let _this = e.target
    let id = _this.getAttribute('couponid')
    id = Number(id)
    location.href='./../html/youhuixiang.html?couponid='+id
    console.log(id)
    
}
span.onclick = function () {
    location.href = "./../index.html"
}
foot.onclick = function () {
    location.href = "./../index.html"
}